/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pkg_group5;

import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import java.util.ArrayList;

/**
 *
 * @author Matt
 */


@WebService()
public class Feedback {

    FeedbackDatabaseFunctions database = new FeedbackDatabaseFunctions();

    @WebMethod
    public String setupFeedbackSystem(@WebParam(name = "username") String username, @WebParam(name = "password") String password) 
    { 
       if (database.setupFeedbackSystem(username, password) >= 0)
       { 
          return "Feedback system registered to: " + username; 
       }

        return "Error setting feedback system up";
    }

    @WebMethod
    public ArrayList getFeedback(@WebParam(name = "SystemID")int SystemID, @WebParam(name = "BookID")int BookID)
    {
        ArrayList<FeedbackItem> feedback = new ArrayList<FeedbackItem>();
        feedback = database.getFeedback(SystemID, BookID);
        return feedback;
    }

    @WebMethod
    public int giveFeedback(@WebParam(name = "SystemID")int SystemID, @WebParam(name = "BookID")int BookID, @WebParam(name = "username")String username, @WebParam(name = "feedback")String feedback)
    {
        if (database.giveFeedback(BookID, SystemID, username, feedback) >= 0)
        {
            return 0;
        }
        return -1;
    }


    
}
